package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;

/**
 * SplashScreens that is shown when the program is started
 * 
 * @author Thomas
 *
 */
public class SplashScreen extends JFrame
{

	public SplashScreen() 
	{
		super("ToWaJoJopoly");
		setUndecorated(true);
        JLabel l = new JLabel(ImageCreator.createImageIcon("Images/splash.png"));
        getContentPane().add(l, BorderLayout.CENTER);
        pack();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension labelSize = l.getPreferredSize();
        setLocation(screenSize.width/2 - (labelSize.width/2),
                    screenSize.height/2 - (labelSize.height/2));
        
        setVisible(true);
        
        waitTime(1500);
     }

	/**
	 * Sets how long the Splash screen will be shown
	 * @param time the time
	 */
	private void waitTime(long time)
	{
		try 
		{
			Thread.sleep(time);
		} 
		catch (InterruptedException e) 
		{
			e.printStackTrace();
		}
		
		this.dispose();
	}
}
